﻿using Minecraft.Config;
using Minecraft.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Minecraft.DALMySql
{
	public class FriendDAL : BaseDAL
	{
		/// <summary>
		/// 向friend表插入数据（分表插入，如果不存在表，则先建立表，并将表名称缓存起来）
		/// </summary>
		/// <param name="model"></param>
		/// <param name="friendTableNameCacheList"></param>
		/// <returns></returns>
		public static bool InsertSuccessForSplitTable(FriendModel model, List<string> friendTableNameCacheList)
		{
			return InsertSuccessModelData(model,
				friendTableNameCacheList,
				model.PlayerId,
				TablePrefixKey.Friend,
				JsonConfig.Value.Mysql.SubmeterLen.FriendTable,
				GetPrefixTableSql);
		}

		public static List<FriendModel> GetListAll(int playerId)
		{
			var model = new FriendModel();
			return GetListAllWithTablePrefix(model, playerId,
				MemorySystemManager.friendTableNameCacheList,
				TablePrefixKey.Friend,
				JsonConfig.Value.Mysql.SubmeterLen.FriendTable,
				new KeyValuePair<string, int>(nameof(model.PlayerId), playerId), GetPrefixTableSql);
		}
	}
}
